package com.cloud.controller;


import com.cloud.entity.Shop;
import com.cloud.feign.ShopFeign;
import com.cloud.service.ShopService;
import com.cloud.util.JsonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * (Shop)表控制层
 *
 * @author makejava
 * @since 2020-11-28 16:29:01
 */
@RestController
@RequestMapping("shop")
public class ShopController implements ShopFeign {

    @Resource
    private ShopService shopService;

    /**
     * @author lc
     * @date 2020/11/28
     * @description 修改库存
     */
    @PostMapping("update")
    public JsonResult update(Long shopId){
        Shop byId = shopService.getById(shopId);
        byId.setNumber(byId.getNumber()-1);
        byId.updateById();
        return JsonResult.okMsg("修改库存成功");
    }

    /**
     * @author lc
     * @date 2020/11/28
     * @description 查询库存
     */
    @GetMapping("find")
    public JsonResult find(Long shopId){
        return JsonResult.okData(shopService.getById(shopId));
    }

}